package com.hengxinguotong.hxgtwygsp.ui.newView.propertySuperviseInfo;

import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.hengxinguotong.hxgtwygsp.R;
import com.hengxinguotong.hxgtwygsp.model.Quarter;
import com.hengxinguotong.hxgtwygsp.model.Year;
import com.hengxinguotong.hxgtwygsp.ui.base.BaseDialogActivity;
import com.hengxinguotong.hxgtwygsp.widget.DoubleListPW;
import com.hengxinguotong.hxgtwygsp.widget.QuarterPW;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 物业管理行政监管信息
 * Created by CS-Yong
 * 2019/9/2  2:49
 */
public class PropertySuperviseInfoActivity extends BaseDialogActivity implements
        DoubleListPW.OnClickCallback<Year, Quarter> {


    @BindView(R.id.tv_img_title)
    TextView mTvImgTitle;
    @BindView(R.id.member_close)
    ImageView mMemberClose;
    @BindView(R.id.supervise_quarter)
    TextView mSuperviseQuarter;
    @BindView(R.id.supervise_quarter_container)
    RelativeLayout mSuperviseQuarterContainer;
    @BindView(R.id.iv_switch)
    ImageView mIvSwitch;
    private List<Year> yearList;
    private String[] mQuarters;

    @Override
    public int getLayoutResId() {
        return R.layout.activity_property_supervise_info;
    }

    @Override
    public void init() {
        yearList = new ArrayList<>();
        mQuarters = getResources().getStringArray(R.array.array_quarter);
        Calendar calendar = Calendar.getInstance();
        mSuperviseQuarter.setText(getString(R.string.patrol_quarter, calendar.get(Calendar.YEAR), mQuarters[0]));
        Year year;
        List<Quarter> quarterList;
        Quarter quarter;
        for (int i = 0; i < 1; i++) {
            year = new Year();
            year.setName(getString(R.string.patrol_year, calendar.get(Calendar.YEAR)));
            year.setValue(calendar.get(Calendar.YEAR));
            quarterList = new ArrayList<>();
            for (int j = 0; j <= 1; j++) {
                quarter = new Quarter();
                quarter.setValue(j);
                quarter.setName(mQuarters[j]);
                quarterList.add(quarter);
            }
            year.setQuarterList(quarterList);
            yearList.add(year);
        }
    }

    @OnClick(R.id.member_close)
    public void onViewClicked() {
        finish();
    }

    @OnClick(R.id.supervise_quarter_container)
    public void onViewClicked(View view) {
        QuarterPW quarterPW = new QuarterPW(this, view.getWidth());
        quarterPW.setOnClickCallback(this);
        quarterPW.initData(yearList);
        quarterPW.showAsDropDown(view);
    }

    @Override
    public void onClickPW(Year year, Quarter quarter) {
        mSuperviseQuarter.setText(getString(R.string.patrol_quarter, year.getValue(), quarter.getName()));

        if (quarter.getName().equals(mQuarters[0])){
            mIvSwitch.setImageResource(R.mipmap.iv_supervise_info_down_1);
        }else if (quarter.getName().equals(mQuarters[1])){
            mIvSwitch.setImageResource(R.mipmap.iv_supervise_info_down_2);
        }


    }


}
